package org.willthink.controller.sample;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
import org.willthink.service.sample.SampleService;

@Controller
public class SampleController 
{
	private Logger logger = Logger.getLogger(getClass());
	
	private final static String USERID = "willthink";
	private final static String USERPW = "bitacademy14";
	private SampleService service;
	
	public void setService(SampleService service) 
	{
		this.service = service;
	}

	@RequestMapping(value="sample.think")
	public ModelAndView init(@RequestParam("id") String id, @RequestParam("pw") String pw)
	{
		if( !USERID.equalsIgnoreCase(id) || !USERPW.equalsIgnoreCase(pw) ) return null;
		logger.info(" oracle connected test : " + service.sample());
		
		ModelAndView mav = new ModelAndView("sample/sample");
		
		return mav;
	}
}
